package comprehensive_case;

import java.util.Random;

public class 抽奖 {
    public static void main(String[] args) {
        int[] arr = { 2, 8, 88, 888, 88888 };

        int[] newArr = new int[arr.length];

        Random r = new Random();
        // 随机抽取放到newArr数组中 判断奖项是否存在
        for (int i = 0; i < arr.length;) {
            int randomIndex = r.nextInt(arr.length);
            if (!iscontain(newArr, arr[randomIndex])) {
                newArr[i] = arr[randomIndex];
                i++;
            }
        }
        for (int i = 0; i < newArr.length; i++) {
            System.out.println(newArr[i]);
        }
    }

    public static boolean iscontain(int[] arr, int choudao) {
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == choudao) {
                return true;
            }
        }
        return false;
    }
}
